from xml.dom import minidom


def writeIframe(ipAddress, port, filehandle):
	filehandle.write('<a href="#" onClick="showWindow(\'' + ipAddress + '\')" ondblclick="CloseWindow(\'' + ipAddress + '\')">' + ipAddress + ':' + port + '</a>\n') 
	filehandle.write('<iframe id="' + ipAddress + '" src="http://' + ipAddress + ':' + port + '" style="height: 0;"></iframe>\n')
	filehandle.write('<p>\n')


outputFile = open('iframe.html', 'w')

xmldoc = minidom.parse('10.49.4.192.xml')

interestingPorts = [80,443,8080,3389]

for dhost in  xmldoc.getElementsByTagName('host'):
	ipAddress = str(dhost.getElementsByTagName('address')[0].getAttributeNode('addr').value)
	for dport in dhost.getElementsByTagName('port'):
		proto = dport.getAttributeNode('protocol').value
		port =  int(dport.getAttributeNode('portid').value)
		state = dport.getElementsByTagName('state')[0].getAttributeNode('state').value
		reason = dport.getElementsByTagName('state')[0].getAttributeNode('reason').value
		
		if (port in interestingPorts):
			port=str(port)
			writeIframe(ipAddress, port, outputFile)
			

				
outputFile.close()		